<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../js/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <style>
        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }
        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>健康评估<small>健康测评</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>健康评估</el-breadcrumb-item>
            <el-breadcrumb-item>健康测评</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <el-input placeholder="档案号/姓名" v-model="pagination.queryString" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter"></el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
                <el-button @click="exportExcel()" class="dalfBut">导出Excel</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="selection" width="55"></el-table-column>
                <el-table-column prop="fileNumber" label="档案号" align="center"></el-table-column>
                <el-table-column prop="name" label="姓名" align="center"></el-table-column>
                <el-table-column prop="assessDate" label="测评日期" align="center"></el-table-column>
                <el-table-column prop="sun_Sum" label="阳虚体质" align="center"></el-table-column>
                <el-table-column prop="mentality_Sum" label="心理评分" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleAdd(scope.row)">新增</el-button>
                        <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
                <el-table-column label="查看报告" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" size="mini" @click="handleLook(scope.row)">查看</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
             <!--新增标签弹层-->
            <div class="add-form">
                <el-dialog title="健康测评" :visible.sync="dialogFormVisible">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="阳虚测评" name="first">
                            <el-form label-position="left" label-width="300px">
                                <el-row>
                                    <el-col :span="20">
                                        <el-form-item label="1.手脚发凉吗">
                                            <el-select v-model="formData.s1">
                                                <el-option label="没有(根本不)" value="0"></el-option>
                                                <el-option label="很少(有一点)" value="1"></el-option>
                                                <el-option label="有时(有些)" value="2"></el-option>
                                                <el-option label="经常(相当)" value="3"></el-option>
                                                <el-option label="总是(非常)" value="4"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="20">
                                        <el-form-item label="2.您胃部,膝部怕冷吗">
                                            <el-select v-model="formData.s2">
                                                <el-option label="没有(根本不)" value="0"></el-option>
                                                <el-option label="很少(有一点)" value="1"></el-option>
                                                <el-option label="有时(有些)" value="2"></el-option>
                                                <el-option label="经常(相当)" value="3"></el-option>
                                                <el-option label="总是(非常)" value="4"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="20">
                                        <el-form-item label="3.您感到怕冷,衣服穿的比别人多吗">
                                            <el-select v-model="formData.s3">
                                                <el-option label="没有(根本不)" value="0"></el-option>
                                                <el-option label="很少(有一点)" value="1"></el-option>
                                                <el-option label="有时(有些)" value="2"></el-option>
                                                <el-option label="经常(相当)" value="3"></el-option>
                                                <el-option label="总是(非常)" value="4"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="20">
                                        <el-form-item label="4.您比别人更不能受寒">
                                            <el-select v-model="formData.s4">
                                                <el-option label="没有(根本不)" value="0"></el-option>
                                                <el-option label="很少(有一点)" value="1"></el-option>
                                                <el-option label="有时(有些)" value="2"></el-option>
                                                <el-option label="经常(相当)" value="3"></el-option>
                                                <el-option label="总是(非常)" value="4"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="20">
                                        <el-form-item label="5.您比别人更容易感冒">
                                            <el-select v-model="formData.s5">
                                                <el-option label="没有(根本不)" value="0"></el-option>
                                                <el-option label="很少(有一点)" value="1"></el-option>
                                                <el-option label="有时(有些)" value="2"></el-option>
                                                <el-option label="经常(相当)" value="3"></el-option>
                                                <el-option label="总是(非常)" value="4"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="20">
                                        <el-form-item label="6.您吃凉的东西会不舒服">
                                            <el-select v-model="formData.s6">
                                                <el-option label="没有(根本不)" value="0"></el-option>
                                                <el-option label="很少(有一点)" value="1"></el-option>
                                                <el-option label="有时(有些)" value="2"></el-option>
                                                <el-option label="经常(相当)" value="3"></el-option>
                                                <el-option label="总是(非常)" value="4"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="20">
                                        <el-form-item label="7.您吃的凉的后或拉肚子吗">
                                            <el-select v-model="formData.s7">
                                                <el-option label="没有(根本不)" value="0"></el-option>
                                                <el-option label="很少(有一点)" value="1"></el-option>
                                                <el-option label="有时(有些)" value="2"></el-option>
                                                <el-option label="经常(相当)" value="3"></el-option>
                                                <el-option label="总是(非常)" value="4"></el-option>
                                            </el-select>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form>
                        </el-tab-pane>
                            <el-tab-pane label="心理测评" name="second">
                                <el-form label-position="left" label-width="300px">
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="1.头痛">
                                                <el-select v-model="mentalityData.m1">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="2.神经过敏，心中不踏实">
                                                <el-select v-model="mentalityData.m2">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="3.头脑中有不必要的想法">
                                                <el-select v-model="mentalityData.m3">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="4.头晕和昏倒">
                                                <el-select v-model="mentalityData.m4">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="5.对异性兴趣减退">
                                                <el-select v-model="mentalityData.m5">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="6.对旁人责备求全">
                                                <el-select v-model="mentalityData.m6">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="7.感到别人能控制你的想法">
                                                <el-select v-model="mentalityData.m7">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="8责怪别人制造麻烦">
                                                <el-select v-model="mentalityData.m8">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="9.忘记性大">
                                                <el-select v-model="mentalityData.m9">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="10.担心自己的服饰整齐及仪态端正">
                                                <el-select v-model="mentalityData.m10">
                                                    <el-option label="没有(根本不)" value="0"></el-option>
                                                    <el-option label="很少(有一点)" value="1"></el-option>
                                                    <el-option label="有时(有些)" value="2"></el-option>
                                                    <el-option label="经常(相当)" value="3"></el-option>
                                                    <el-option label="总是(非常)" value="4"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false">取消</el-button>
                        <el-button type="primary" @click="handleSub()">确定</el-button>
                    </div>
                </el-dialog>
            </div>

            <!-- 编辑标签弹层 -->
            <div class="add-form">
                <el-dialog title="查看测评报告" :visible.sync="dialogFormVisible4Edit">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="阳虚体质" name="first">
                                <el-form label-position="left" label-width="300px">
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="1.手脚发凉吗">
                                                <el-input v-model="formData.s1"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="2.您胃部,膝部怕冷吗">
                                                <el-input v-model="formData.s2"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="3.您感到怕冷,衣服穿的比别人多吗">
                                                <el-input v-model="formData.s3"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="4.您比别人更不能受寒">
                                                <el-input v-model="formData.s4"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="5.您比别人更容易感冒">
                                                <el-input v-model="formData.s5"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="6.您吃凉的东西会不舒服">
                                                <el-input v-model="formData.s6"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="7.您吃的凉的后或拉肚子吗">
                                                <el-input v-model="formData.s7"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                            <el-tab-pane label="心理测评" name="second">
                                <el-form label-position="left" label-width="300px">
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="1.头痛">
                                                <el-input v-model="mentalityData.m1"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="2.神经过敏，心中不踏实">
                                                <el-input v-model="mentalityData.m2"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="3.头脑中有不必要的想法">
                                                <el-input v-model="mentalityData.m3"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="4.头晕和昏倒">
                                                <el-input v-model="mentalityData.m4"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="5.对异性兴趣减退">
                                                <el-input v-model="mentalityData.m5"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="6.对旁人责备求全">
                                                <el-input v-model="mentalityData.m6"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="7.感到别人能控制你的想法">
                                                <el-input v-model="mentalityData.m7"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="8.责怪别人制造麻烦">
                                                <el-input v-model="mentalityData.m8"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="9.忘记性大">
                                                <el-input v-model="mentalityData.m9"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="20">
                                            <el-form-item label="10.担心自己的服饰整齐及仪态端正">
                                                <el-input v-model="mentalityData.m10"/>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </el-form>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">取消</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    var vue = new Vue({
        el: '#app',
        data:{
            activeName:'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                currentPage: 1,
                pageSize:10,
                total:100,
                queryString:null,
            },
            dataList: [],//列表数据
            formData: {},//表单数据
            tableData:[],//新增和编辑表单中对应的检查项列表数据
            mentalityData:{},//新增和编辑表单中检查项对应的复选框，基于双向绑定可以进行回显和数据提交
            dialogFormVisible: false,//控制添加窗口显示/隐藏
            dialogFormVisible4Edit:false,//控制编辑窗口显示/隐藏
            obj:[],
            fileNum :''
        },
        created() {
            this.findPage();
        },
        methods: {
            //导出excel表
            exportExcel() {
                window.location.href='/report/exportHealthQuestionnaire.do';
            },
            //确定提交
            handleSub() {
                // alert(this.fileNum)
                this.obj[0] = this.fileNum;
                this.obj[1] = this.formData;
                this.obj[2] = this.mentalityData;

                axios.post("/assessment/add.do",this.obj).then((resp) => {
                    if (resp.data.flag) {
                        this.$message({
                                type: "success",
                                message: resp.data.message
                            },
                            this.findPage());
                    } else {
                        this.$message.error(resp.data.message)
                    }
                }).finally( () => {
                    this.dialogFormVisible = false;
                    this.findPage();
                })

            },
            //添加
            handleAdd (row) {
                // alert(row.fileNumber);
               this.dialogFormVisible = true;
               this.resetForm();
               this.fileNum=row.fileNumber;

            },
            //分页查询
            findPage() {
                axios.post("/assessment/findPage.do", this.pagination).then((resp) => {
                    this.pagination.total = resp.data.total;
                    this.dataList = resp.data.rows;
                })
            },
            // 重置表单
            resetForm() {
                this.formData = {};
                this.mentalityData = {};
            },
            // 弹出查看窗口
            handleLook(row) {
                this.dialogFormVisible4Edit = true;
                this.fileNum=row.fileNumber;
                this.obj[0] = this.fileNum;
                //发送ajax请求，查询所有的检查项信息，转为json，赋值给tableData
                this.activeName = 'first';//默认选中first对应的tab
                axios.post("/assessment/findAll.do",this.obj).then((resp) => {
                    if (resp.data.flag) {
                        this.$message({
                                type: "success",
                                message: resp.data.message
                            },
                            this.formData = resp.data.data[0],
                            this.mentalityData = resp.data.data[1],
                            this.findPage());
                    } else {
                        this.resetForm();
                        this.$message.error(resp.data.message)
                    }
                });
            },
            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;
                this.findPage();
            },
            // 删除
            handleDelete(row) {
                this.$confirm("您确定要删除当前数据吗?","提示",{
                    type: "warning"
                }).then(
                    ()=>{
                        //点击了 确定,,然后发送请求
                        axios.get("/assessment/delete.do?fileNumber="+row.fileNumber).then((resp)=>{
                            if (resp.data.flag){
                                this.$message({
                                        type : "success",
                                        message : resp.data.message
                                    },
                                    this.findPage());
                            } else {
                                this.$message.error(resp.data.message)
                            }
                        })
                    }
                ).catch(
                    ()=>{
                        this.$message({
                            thyp : "info",
                            message : "操作取消"
                        })
                    }
                );
            }
        }
    })
</script>
</html>
